#include"Siruri.h"
Siruri::Siruri(void)
{
    dim=1;
    s=new char[dimens];
    if(!s)
     {
         cout<<"Eroare la alocare!"<<endl;
         exit(1);
     }
     *s='\0';
}
Siruri::Siruri(char *sir)
{
    dim=strlen(sir) +1;
    s=new char[dimens];
    if(!s)
    {
        cout<<"Eroare!"<<endl;
        exit(1);
    }
    strcpy(s,sir);
}
Siruri::Siruri(const Siruri &obiect)
{
    dim=obiect.dim;
    s=new char[dime];
    if(!s)
    {
        cout<<"Eroare!"<<endl;
        exit(1);
    }
    strcpy(s,obiect.s);
}
ostream &operator<<(ostream &fl, Siruri &obiect)
{
    fl<<obiect.s;
    return fl;
}
Siruri Siruri::operator=(Siruri &obiect)
{
    Siruri temp(obiect.s);
    if(obiect.dim>dim)
    {
        delete s;
        s = new char[obiect.dimens];
        dim=obiect.dim;
        if(!s)
        {
            cout<<"Eroare!"<<endl;
            exit(1);
        }
    }
    strcpy(s, obiect.s);
    strcpy(temp.s,obiect.s);
    return temp;
}

Siruri Siruri::operator=(char *q)
{
    int lungime=strlen(q) + 1;
    if(dim<lungime)
    {
        delete s;
        s=new char[lungime];
        dim=lungime;
        if(!s)
        {
            cout<<"Eroare!"<<endl;
            exit(1);
        }
    }
    strcpy(p,q);
    return *this;
}

